package com.aio.kgo.simple.form.design.config;

import com.aio.kgo.simple.form.common.exceptions.ModelAlreadyExistException;
import com.kgo.flow.common.domain.amis.AmisResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class HandleSimpleModelException {
    @ExceptionHandler(value = ModelAlreadyExistException.class)
    @ResponseBody
    public AmisResult handleModelAlreadyExistException(ModelAlreadyExistException ex) {
        log.error("模型已存在异常 :[ {} ],异常追踪 ：  {}", ex.getMessage(),ex.getStackTrace());
        AmisResult fail = AmisResult.fail(50001, ex.getMessage());
        return fail;
    }
}
